import { v1 as uuid, parse as uuidParse ,stringify} from '../../thirdy/uuid';
export class Guid {

    private _uuid: string = '';
    public get uuid(): string {
        return this._uuid;
    }
    public set uuid(value: string) {
        this._uuid = value;
    }

    static newGuid(): Guid {
        return new Guid(uuid());
    }

    static empty(): Guid {
        return new Guid('00000000-0000-0000-0000-000000000000');
    }

    constructor(uuid: string | Uint8Array) {
        if (typeof uuid === 'string') {
            this._uuid = uuid;
        } else {
            this._uuid = stringify(uuid);
        }
    }

    toByteArray(): Uint8Array {
        return uuidParse(this._uuid);
    }
}
